package com.my.study.designPatterns.iteratorPattern;

import java.util.ArrayList;
import java.util.List;

public class PancakeHouseMenu implements Menu{

    private List<MenuItem> menuItems;


    public PancakeHouseMenu() {

       menuItems = new ArrayList<>();

       addItem("K&B Pancake for Breakfast", true, 8.88, "Beautiful");
       addItem("Clock Pancake for Breakfast", true, 8.78, "Pretty");
       addItem("Frost Pancake for Breakfast", false, 7.88, "Generous");
       addItem("A&A Pancake for Breakfast", false, 4.88, "Kind");
       addItem("C&C Pancake for Breakfast", true, 4.88, "Nice");

    }


    public void addItem(String name, Boolean vegetable, Double price, String description){

        menuItems.add(new MenuItem(name, vegetable, price, description));
    }

    public Iterator<MenuItem> getPancakeHouseMenuIterator(){

        return new PancakeHouseMenuIteraotor(menuItems);
    }


    //更近一层，将getPancakeHOuseMenuIterator 方法抽象出来
    @Override
    public Iterator<MenuItem> createIterator() {
        return new PancakeHouseMenuIteraotor(menuItems);
    }
}
